/*
 * Copyright (C) 2010 by CODEBISTRO LLC.
 *
 * The license is granted to use, reproduce, modify, display, perform, sublicense
 * and distribute this code under the conditions of the Mozilla Public License v 1.1.
 *
 * The text of the license is available with this source as MPL-1.1.txt
 * or at http://www.mozilla.org/MPL/MPL-1.1.txt.
 */

package org.codebistro.tools;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import java.io.File;

public class BuildNumberTask extends Task {
    BuildNumber rep= new BuildNumber();

    public void setBuildDirectory(File buildDirectory) {
        rep.setBuildDirectory(buildDirectory);
    }

    public void setBasedir(File basedir) {
        rep.setBasedir(basedir);
    }

    public void setOutputPath(File outputPath) {
        rep.setOutputPath(outputPath);
    }

    @Override
    public void execute() throws BuildException {
        try {
            String result= rep.execute(true);
            log("[INFO] Generated build number=" + result + " in " +
                    rep.getOutputPath().getAbsolutePath());
        } catch (Exception e) {
            throw new BuildException(e.getCause());
        }
    }
}
